package com.controller.chart;

import com.model.pojo.annotation.CheckToken;
import com.model.pojo.RepEntity;
import com.model.vo.configVo.*;
import com.server.chart.*;
import com.server.dataSource.ColumnScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

@RestController
public class ShowChartsController {

    @Autowired
    ShowHistogramService showHistogramService;
    @Autowired
    ShowPieService showPieService;
    @Autowired
    ShowLineService showLineService;
    @Autowired
    ShowScatterService showScatterService;
    @Autowired
    ShowIndividualService showIndividualService;
    @Autowired
    ShowPopulationService showPopulationService;
    @Autowired
    ColumnScreenService columnScreenService;
    @Autowired
    GetChartsDataUtilService getChartsDataUtilService;
    /*
    展示柱状图
     */
    @CheckToken
    @RequestMapping("/showHistogram")
    public RepEntity showHistogram(@RequestHeader String token,@RequestBody HistogramConfigInfo body){
        return showHistogramService.showHistogram(body, token, 0);
    }

    /*
    展示饼图
     */
    @CheckToken
    @RequestMapping("/showPie")
    public RepEntity showPie(@RequestHeader String token,@RequestBody PieConfigInfo body){
        return showPieService.showPie(body, token, 0);
    }

    /*
    展示Line
     */
    @CheckToken
    @RequestMapping("/showLine")
    public RepEntity showLine(@RequestHeader String token,@RequestBody LineConfigInfo body){
        return showLineService.showLine(body, token, 0);
    }

    /*
    showScatter
     */
    @CheckToken
    @RequestMapping("/showScatter")
    public RepEntity showScatter(@RequestHeader String token,@RequestBody ScatterConfigInfo body){
        return showScatterService.showScatter(body, token, 0);
    }

    /*
    show个体统计表
     */
    @CheckToken
    @RequestMapping("/showIndividual")
    public RepEntity showIndividual(@RequestHeader String token,@RequestBody IndividualConfigInfo body){
        return showIndividualService.showIndividual(body, token, 0);
    }

    /*
    show总体统计表
     */
    @CheckToken
    @RequestMapping("/showPopulation")
    public RepEntity showPopulation(@RequestHeader String token,@RequestBody PopulationInfo body) throws SQLException {
        return showPopulationService.showPopulation(body, token, 0);
    }

    /*
    展示单列数据
     */
    @CheckToken
    @RequestMapping("/showScreenData")
    public RepEntity showScreenData(@RequestHeader String token,@RequestBody ColumnScreenInfo body){
        return columnScreenService.getScreenData(body, token);
    }

    /*
    展示单列数据（数据源）
     */
    @CheckToken
    @RequestMapping("/getScreenByBaseId")
    public RepEntity getScreenByBaseId(@RequestHeader String token,@RequestBody ColumnScreenInfo body){
        return columnScreenService.getScreenByBaseId(body, token);
    }

    /*
    展示图表数据信息
     */
    @CheckToken
    @RequestMapping("/getChartsData")
    public RepEntity getChartsData(@RequestHeader String token,@RequestBody ShowDataChartInfo body){
        return getChartsDataUtilService.getChartsData(token, body);
    }
}
